<div id="category">
    <?php
    if(isset($cat_list) && count($cat_list) > 0)
    {
        $currentLevel = 0;
        $first = TRUE;
        echo "<ul id='menu_cat'>";
        foreach($cat_list as $cat)
        {
            if($cat->c_level == $currentLevel)
            {
                if($first)
                {
                    $first = FALSE;
                    echo "<li><img src='" . (Utility::getSiteUrl() . '/public/images/arrow/' . ($cat->c_level % 2 == 1?'ar1.png':'ar2.png')) . "' /><a href='" . (strlen($cat->link) == 0?Utility::getSiteUrl() . "/category/show/$cat->id":$cat->link) . "' style='text-decoration:none'>$cat->name</a>";
                }
                else
                    echo "</li><li><img src='" . (Utility::getSiteUrl() . '/public/images/arrow/' . ($cat->c_level % 2 == 1?'ar1.png':'ar2.png')) . "' /><a href='" . (strlen($cat->link) == 0?Utility::getSiteUrl() . "/category/show/$cat->id":$cat->link) . "' style='text-decoration:none'>$cat->name</a>";
            }
            elseif($cat->c_level > $currentLevel)
            {
                echo "<ul>";
                echo "<li><img src='" . (Utility::getSiteUrl() . '/public/images/arrow/' . ($cat->c_level % 2 == 1?'ar1.png':'ar2.png')) . "' /><a href='" . (strlen($cat->link) == 0?Utility::getSiteUrl() . "/category/show/$cat->id":$cat->link) . "' style='text-decoration:none'>$cat->name</a>";
                $currentLevel = $cat->c_level;
                
            }
            else
            {
                echo "</li></ul>";
                for($i = $currentLevel - 1; $i > $cat->c_level;$i--)
                echo "</li></ul>";
                echo "</li><li><img src='" . (Utility::getSiteUrl() . '/public/images/arrow/' . ($cat->c_level % 2 == 1?'ar1.png':'ar2.png')) . "' /><a href='" . (strlen($cat->link) == 0?Utility::getSiteUrl() . "/category/show/$cat->id":$cat->link) . "' style='text-decoration:none'>$cat->name</a>";
                $currentLevel = $cat->c_level;
                
            }
            
        }
        echo "</li>";
        echo "</ul>";
    }
     ?>
 <!--   <ul id="menu_cat">
        <li><a href="#">Tin tuc</a>
            <ul>
                <li><a href="#">Tro choi</a></li>
                <li><a href="#">Su kien</a></li>
            </ul>
        </li>
        <li><a href="#">Thu vien</a>
            <ul>
                <li><a href="#">Anh</a></li>
                <li><a href="#">Video</a></li>
            </ul>
        </li>
    </ul> -->
</div>